package com.campol.view;

import android.content.Context;
import android.graphics.Color;
import android.graphics.PorterDuff.Mode;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.campol.R;

public class TabBarButton extends LinearLayout{

	public TabBarButton(Context context) {
		super(context);
		initLayout(context);
	}
	
	public TabBarButton(Context context, AttributeSet attrs) {
		super(context, attrs);
		initLayout(context);
	}

	private void initLayout(Context context) {
		LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		inflater.inflate(R.layout.tab_button_view, this, true);
	}
	
	public void setButtonText(String text) {
		((TextView)findViewById(R.id.tab_button_text)).setText(text);
	}
	
	public void setButtonIcon(int iconRes) {
		((ImageView)findViewById(R.id.tab_button_icon)).setImageResource(iconRes);
	}
	
	public void setTabButtonPressed(boolean pressed) {
		if (pressed) {
			((ImageView)findViewById(R.id.tab_button_icon)).setColorFilter(Color.rgb(0x00, 0xb6, 0xe0), Mode.SRC_ATOP);
		} else {
			((ImageView)findViewById(R.id.tab_button_icon)).setColorFilter(Color.WHITE, Mode.SRC_ATOP);
		}
	}	
}
